<?php
namespace Management\Controller;
use Think\Controller;
class IndexController extends BaseController {


    public function index(){
		
		
		$this->display();
    }
	
	
    public function addTop(){
		
		$this->display('top');
    }	
	
    public function addLeft(){
		header('Content-Type:text/html;charset=utf-8');

		$subNav = C('NAV');
		
//		$moduleList = D('Base')->listModules();
//
//		foreach($moduleList as $item){
//			$itemNav = $this->getModuleNav($item);
//			if($itemNav){
//				$subNav[$item."ExtraManage"] =$itemNav;
//			}
//		}
		//die(json_encode($subNav));
		
		$mobilePower = M('admin_config')->getField('is_mobile');
		
	    if(!$mobilePower){
			unset($subNav['mobileManage']);
		}
		
		if(!C('SHOP_POWER')){
			unset($subNav['shopManage']);
		}
		if(!C('MEM_POWER')){
			unset($subNav['memberManage']);
		}
		
		
		
		$this->assign('subNav',$subNav);
		
		$this->display('left');
    }	
	
	
	
	
    public function addMain(){
		

		$subNav = C('NAV');
		$this->assign('subNav',$subNav);		
		
		$map['language'] = cookie('AUTH_USER_LANG');
		
		$circle['news']    = M('news')->where($map)->getField('count(*)');
		$circle['product'] = M('shop_product')->where($map)->getField('count(*)');
		$circle['msg']     = M('msg')->where($map)->where('status=0')->getField('count(*)');
		$circle['common']  = M('common')->where($map)->getField('count(*)');
		$circle['member']  = M('member')->getField('count(*)');
		$circle['atm']     = M('atm')->where($map)->getField('count(*)');
		$circle['link']    = M('link')->where($map)->getField('count(*)');
		$circle['order']   = M('shop_product_order')->getField('count(*)');
		
		$this->assign('circle',$circle);
		
		$userKeys[] = 'newsManage';
		$userKeys[] = 'productManage';
		$userKeys[] = 'shopManage';
		$userKeys[] = 'msgManage';
		$userKeys[] = 'commonManage';
		$userKeys[] = 'memberManage';
		$userKeys[] = 'atmManage';
		$userKeys[] = 'linkManage';
		$userKeys[] = 'shopManage';
		$service = require(rtrim(__PHYSICS__,'\\').'/Common/Conf/service.php');
		$where['section_name'] = '新增';
		$insert =M('user_log_detail')->where($where)->count();
		$where['section_name'] = '修改';
		$update =M('user_log_detail')->where($where)->count();
		$fuwu= '对网站增加数据服务'.$insert.'次,对网站修改数据服务'.$update.'次';
		$this->assign('userKeys',$userKeys);
		$this->assign('fuwu',$fuwu);
		$this->assign('service',$service);
		$this->display('main');
    }	
	
    public function addFoot(){
		
		$this->display('foot');
    }	
	
	
	public function download(){
		
		$this->display();
    }	
	
	public function getModuleNav($moduleName){
		$folderPath = dirname(__FILE__)."/../Conf/ModuleNav/";
		$fileName = strtolower($moduleName)."_nav.php"; 
		$resultNav = $this->readNav($folderPath.$fileName);
		return $resultNav;
	}
	
	private function readNav($filepath){
		$itemStr = str_replace(array('<?php','?>'),'',file_get_contents($filepath));
		$itemStr = mb_convert_encoding($itemStr,'UTF-8',"auto");
		return eval($itemStr);
	}
	public function HtmlMd5(){
        HtmlMd5('Index');
        $this->ajaxReturn('Md5文件更新完成');
    }
	
}